@extends('admin.layout.layout')
@section('title','链接列表')
@section('content')
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">链接列表</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
		 <div class="panel-body">
		    <div class="dataTable_wrapper"> 
	   			<div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
	    			<div class="row">
	    				<form action="{{url('admin/cate/index')}}">
					     <div class="col-sm-6">
					      <div class="dataTables_length" id="dataTables-example_length">
					       	<label>每页显示 
					       		<select name="num" aria-controls="dataTables-example" class="form-control input-sm">
					       		<option value="10"
					       		
					       		>10</option>
					       		<option value="25" 
					       	
					       		>25</option>
					       		<option value="50"
					       		
					       		>50</option>
					       		<option value="100"
					       		
					       		>100</option>
					       		</select> 条</label>
					      </div>
					     </div>
					     <div class="col-sm-6">
					      <div id="dataTables-example_filter" class="dataTables_filter">
					       <label>搜索:<input name="keywords" value="{{$list['$keywords'] or ''}}" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" type="search" /></label>
					       <button class="btn btn-primary">查询</button>
					      </div>
					     </div>
	    			</div>
	    			</form>
	    			<div class="row">
	     <div class="col-sm-12">
	      <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info"> 
	       <thead> 
	        <tr role="row">
	         <th>链接id</th>
	         <th>链接名</th>
	         <th>商品图片</th>
	         <th>链接地址</th>
	         <th>操作</th>
	        </tr> 
	       </thead> 
	       <tbody> 
	       @foreach($links as $k=>$v)
	        <tr class="gradeA odd" role="row"> 
	         <td class="sorting_1">{{$v->lid}}</td>
	         <td class="center">{{$v->lname}}</td> 
	         <td align="center"><img src="{{$v->lpic}}" style="height:80px;width:80px" alt=""></td>  
	         <td class="center">{{$v->ladds}}</td> 
	         <td class="center"><button class="btn btn-danger delete">删除</button>
	         <a class="btn btn-primary" href="/admin/link/edit?id={{$v->lid}}">修改</a></td> 
	        </tr>
	        @endforeach

	       </tbody> 
	      </table>
	     </div>
	   </div>
	   <!-- 分页 -->
	   <div class="row">
	     
	   </div>
	   </div> 
	  </div> 
		 <!-- /.table-responsive -->
		    
	</div>
   </div>
     
        <!-- /.row -->
 </div>
 @endsection
 @section('js')
 	<script type="text/javascript">
 		$.ajaxSetup({
	        headers: {
	            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
	        }
		});
 		//绑定单击事件
 		$('.delete').click(function(){
 			if(!confirm('是否删除')){return}
 			var id = $(this).parents('tr').find('.sorting_1').html();
 			var btn = $(this);
	 		//发送ajax
	 		$.post('/admin/link/delete',{id:id},function(data){
	 			if(data == 1){
	 				//删除成功
	 				btn.parents('tr').remove(); 
	 				alert('删除成功');
	 			}else{
	 				//删除失败
	 				alert('删除失败');
	 			}
	 		});
 		})
 	</script>
 @endsection